package org.cuatrovientos.erp.business;

import java.util.List;

import org.apache.log4j.Logger;
import org.cuatrovientos.erp.dao.StateDAOInterface;
import org.cuatrovientos.erp.model.State;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Holds all the business logic for State related management
 * @author VB
 */
public class StateBO implements StateBOInterface {
	
	// Get log4j logger
	private static final Logger logger = Logger.getLogger(StateBO.class);
	
	@Autowired
    private StateDAOInterface stateDAO;

	@Override
	public State selectById(int id) {
		logger.info("selectById: " + id);
		return stateDAO.selectById(id);
	}

	@Override
	public List<State> selectAll() {
		logger.info("selectAll: ");
		return stateDAO.selectAll();
	}

	@Override
	public List<State> search(String name) {
		logger.info("search : " + name);
		return stateDAO.search(name);
	}

	@Override
	public void deleteById(int id) {
		logger.info("delete: " + id);
		 stateDAO.deleteById(id);
	}

	@Override
	public void insert(State state) {
		logger.info("insert: " + state);
		stateDAO.insert(state);
	}

	@Override
	public void update(State state) {
		logger.info("update: " + state);
		stateDAO.update(state);
	}
	
	public void delete(State state){
		logger.info("delete: " + state);
		stateDAO.delete(state);
	}
}
